package com.bilibili.juc.set;

import java.util.Iterator;


public class MyIterator<T> implements Iterable<T>{

    private T[] arr;
    private int index;

    public MyIterator(T[] arr) {
        this.arr = arr;
    }

    /*@Override
    public Iterator<T> iterator() {
        return new Iterator<T>() {

            @Override
            public boolean hasNext() {
                return index < arr.length;
            }

            @Override
            public T next() {
                return arr[index++];
            }

            ;
        };
    }*/
 @Override
    public Iterator<T> iterator() {
        return new MyIteratorInner();
    }

    class MyIteratorInner implements Iterator<T>{

        @Override
        public boolean hasNext() {
            return index < arr.length;
        }

        @Override
        public T next() {
            return arr[index++];
        }
    }




}
